<?php
/**
 * @author: zhouzhongyuan <435690026@qq.com>
 */


namespace webservice\serviceActions;


use ReflectionClass;
use webservice\helpers\WebService;
use yii\base\Object;

abstract class ServiceAction extends Object
{
    public function init()
    {
        parent::init();
        if (!WebService::isSoap()) {
            foreach (\Yii::$app->request->getBodyParams() as $name => $value)
                $this->set($name, $value);
        }
    }

    abstract public function get($name = null);

    abstract public function set($name, $value);

    public function getClasAllMethods()
    {
        $r = new ReflectionClass($this);
        $methods = [];
        foreach ($r->getMethods() as $key => $methodObj) {
            if ($methodObj->isPrivate())
                $methods[$key]['type'] = 'private';
            elseif ($methodObj->isProtected())
                $methods[$key]['type'] = 'protected';
            else
                $methods[$key]['type'] = 'public';
            $methods[$key]['name'] = $methodObj->name;
        }
        return $methods;
    }
}